﻿<UserControl x:Class="RZD_maps.Modules.Map.ViewModel.NavigationControls" x:Name="this"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             >
    <UserControl.Resources>
        <SolidColorBrush x:Key="BackgroundBrush" Color="#C222" />
        <SolidColorBrush x:Key="HighlightedBrush" Color="#FFFF" />
        <SolidColorBrush x:Key="NormalBrush" Color="#7FFF" />

        <Style x:Key="FlatButton" TargetType="{x:Type Button}">
            <Setter Property="BorderBrush" Value="Transparent" />
            <Setter Property="CommandTarget" Value="{Binding ElementName=this, Path=MapItem}" />
            <Setter Property="Focusable" Value="False" />
            <Setter Property="Foreground" Value="{StaticResource NormalBrush}" />
            <Setter Property="Padding" Value="3" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" Background="Transparent" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
                            <Path DataContext="{TemplateBinding Content}" Data="{Binding}" Fill="{TemplateBinding Foreground}" Stroke="{TemplateBinding Foreground}" Stretch="Fill" />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="BorderBrush" Value="{StaticResource NormalBrush}" />
                                <Setter Property="Foreground" Value="{StaticResource HighlightedBrush}" />
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="BorderBrush" Value="{StaticResource HighlightedBrush}" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <ControlTemplate x:Key="EmptyTemplate" TargetType="{x:Type RepeatButton}">
            <Border Background="Transparent" />
        </ControlTemplate>

        <ControlTemplate x:Key="SliderThumbTemplate" TargetType="{x:Type Thumb}">
            <Path x:Name="path" Height="9" Data="M4,0 L1,0 0,1 1,2 4,2 Z" Stroke="{StaticResource NormalBrush}" Stretch="Fill">
                <Path.Fill>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                        <GradientStop Offset="0.05" Color="#666"/>
                        <GradientStop Offset="0.25" Color="#404040"/>
                        <GradientStop Offset="0.95" Color="#FF222222"/>
                    </LinearGradientBrush>
                </Path.Fill>
            </Path>
            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Stroke" TargetName="path" Value="{StaticResource HighlightedBrush}" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>

        <Style x:Key="ZoomSlider" TargetType="{x:Type Slider}">
            <Setter Property="Foreground" Value="{StaticResource NormalBrush}" />
            <Setter Property="Orientation" Value="Vertical" />
            <Setter Property="TickPlacement" Value="TopLeft" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Slider}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <TickBar Grid.Column="0" Width="5" Fill="{TemplateBinding Foreground}" Placement="Left" HorizontalAlignment="Left" />
                            <Path Grid.Column="1" Margin="0,4,4,4" Data="M0,1 L0,0 5,0 1,1 z" Stretch="Fill" Stroke="{TemplateBinding Foreground}">
                                <Path.Fill>
                                    <LinearGradientBrush StartPoint="0,1" EndPoint="0,0">
                                        <GradientStop Offset="0" Color="#3000"/>
                                        <GradientStop Offset="0.8" Color="#407F7F7F"/>
                                    </LinearGradientBrush>
                                </Path.Fill>
                            </Path>
                            <Track Grid.Column="1" x:Name="PART_Track">
                                <Track.DecreaseRepeatButton>
                                    <RepeatButton Command="Slider.DecreaseLarge" Template="{StaticResource EmptyTemplate}" />
                                </Track.DecreaseRepeatButton>
                                <Track.Thumb>
                                    <Thumb Template="{StaticResource SliderThumbTemplate}"/>
                                </Track.Thumb>
                                <Track.IncreaseRepeatButton>
                                    <RepeatButton Command="Slider.IncreaseLarge" Template="{StaticResource EmptyTemplate}" />
                                </Track.IncreaseRepeatButton>
                            </Track>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <StackPanel VerticalAlignment="Top" HorizontalAlignment="Left" Orientation="Horizontal">
        <!-- Zoom control -->
        <Grid Background="{StaticResource BackgroundBrush}" HorizontalAlignment="Left" VerticalAlignment="Bottom">
            <StackPanel>
                <Button Margin="5" Padding="1" Style="{StaticResource FlatButton}" Command="IncreaseZoom" Content="M0,1 L 2,1 M1,0 L 1,2" Height="15" Width="15" />
                <Slider Margin="5,0" Width="20" Height="150" Minimum="0" Maximum="18" Style="{StaticResource ZoomSlider}"
                Value="{Binding ElementName=this, Path=MapItem.Zoom}" />
                <Button Margin="5" Padding="1" Style="{StaticResource FlatButton}" Command="DecreaseZoom" Content="M0,0 L 1,0" Height="15" Width="15" />
            </StackPanel>
        </Grid>
        <!-- Pan controls -->
        <Grid Background="{StaticResource BackgroundBrush}" HorizontalAlignment="Left" VerticalAlignment="Top">
            <Grid Height="30" Width="30" Margin="5">
                <Grid.LayoutTransform>
                    <RotateTransform Angle="45" />
                </Grid.LayoutTransform>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Rectangle Grid.ColumnSpan="2" Grid.RowSpan="2" Stroke="#7FFF" />
                <Button Grid.Column="0" Grid.Row="0" Style="{StaticResource FlatButton}" Command="MoveUp" Content="M0,0 L1,0 0,1 Z" ToolTip="Pan up" />
                <Button Grid.Column="1" Grid.Row="0" Style="{StaticResource FlatButton}" Command="MoveRight" Content="M0,0 L1,0 1,1 Z" ToolTip="Pan right" />
                <Button Grid.Column="0" Grid.Row="1" Style="{StaticResource FlatButton}" Command="MoveLeft" Content="M0,0 L0,1 1,1 Z" ToolTip="Pan left" />
                <Button Grid.Column="1" Grid.Row="1" Style="{StaticResource FlatButton}" Command="MoveDown" Content="M0,1 L1,1 1,0 Z" ToolTip="Pan down" />
            </Grid>
        </Grid>
    </StackPanel>
</UserControl>
